<?php
	namespace app\controllers\test_study;
	use yii\web\Controller;
	use app\models\test_study\table1;
	class SqlinsertController extends Controller{
		public function actionIndex(){
			$table1 = new table1;
			$table1->id = '14';
			$table1->title = 't1fffsdfsdfsdfsdf';
			//启用验证器，model里面的rules函数
			//其实用不用下面那个函数都会执行rules标准，只是用了和这个函数，如果数据有问题，hasErrors会有显示
			$table1->validate();
			if($table1->hasErrors())
				echo "data has errors";
			else{
				$table1->save();
				echo "insert data success";
			}
		}
	}
?>